from ddddocr import DdddOcr


def get_distance(back_path, target_path):
    """
    传入两个路径，检测滑块应该滑动的距离
    :param back_path:背景图片
    :param target_path:目标滑块
    :return:
    """
    det = DdddOcr(show_ad=False, det=False, ocr=False)
    with open(back_path, 'rb') as f:
        back = f.read()
    with open(target_path, 'rb') as f:
        target = f.read()
    ret = det.slide_match(target, back, simple_target=True)
    distance = ret['target'][0]
    return distance


def det_eg():
    distance = get_distance(back_path='../part13/imgs/background.png', target_path='../part13/imgs/target.png')
    print(distance)


if __name__ == '__main__':
    det_eg()

